package com.bsy.common.base

import androidx.lifecycle.MutableLiveData
import com.bsy.common.viewmodel.BaseViewModel

/**
 * Created by Sincerity on 2023/10/20.
 * Copyright
 * 描述：
 */
abstract class BaseRefreshViewModel<T> : BaseViewModel() {
    private var mFinishRefreshEvent = MutableLiveData<List<T>>()
    private var mFinishLoadMoreEvent = MutableLiveData<List<T>>()
    var pageNum = 1

    /**
     * null:失败,size==0:成功,size!=0:执行onRefreshSuccess
     */
    open fun getFinishRefreshEvent(): MutableLiveData<List<T>> {
        return mFinishRefreshEvent
    }

    /**
     * null:失败,size==0:成功,size!=0:执行onLoadMoreSuccess
     */
    open fun getFinishLoadMoreEvent(): MutableLiveData<List<T>> {
        return mFinishLoadMoreEvent
    }

    /**
     * 当界面下拉刷新时,默认直接结束刷新
     */
    open fun onViewRefresh() {
        getFinishRefreshEvent().value = emptyList()
    }

    /**
     * 当界面下拉更多时,默认没有更多数据
     */
    open fun onViewLoadMore() {
        getFinishLoadMoreEvent().value = emptyList()
    }
}